package thesis.filesharing.common.exception.functional;

import java.util.List;

public class InvalidArgumentException extends AppFunctionalException {

	private static final long serialVersionUID = -7988060409012819579L;
	
	private List<String> arguments;
	
	public InvalidArgumentException() {
		super();
	}
	
	public InvalidArgumentException(Throwable throwable) {
		super(throwable);
	}
	
	public InvalidArgumentException(String msg, Throwable throwable) {
		super(msg, throwable);
	}
	
	public InvalidArgumentException(Throwable throwable, List<String> arguments) {
		super(throwable);
		this.arguments = arguments;
	}
	
	public InvalidArgumentException(String msg, Throwable throwable, List<String> arguments) {
		super(msg, throwable);
		this.arguments = arguments;
	}

	public List<String> getArguments() {
		return arguments;
	}

	public void setArguments(List<String> arguments) {
		this.arguments = arguments;
	}
	
	private String getArgumentNames() {
		StringBuilder builder = new StringBuilder();
		for (String arg : arguments) {
			builder.append(arg).append(", ");
		}
		return builder.toString();
	}
	
	@Override
	public String getMessage() {
		String errorMsg = String.format("InvalidArgumentException has been thrown. Invalid argument(s) includes: %s", getArgumentNames());
		return new StringBuffer(errorMsg).append(super.getMessage()).toString();
	}
}
